const express = require("express");
const user = express.Router();
const auth = require("../../middleware/auth");
const {
    Login,
    Register,
    Update,
    Detail,
    Logout,
} = require("../../controller/user");
const { ListBlog } = require("../../controller/blog");
const {
    loginRules,
    registerRules,
    updateRules,
    detailRules,
} = require("../../verify/user");
const { listRules } = require("../../verify/blog");

// 登录
user.post("/login", loginRules, Login);
// 注册
user.post("/register", registerRules, Register);
// 注销
user.get("/logout", auth, Logout);
// 更新
user.patch("/:id", auth, updateRules, Update);
// 详情
user.get("/:id", detailRules, Detail);
// 用户博客列表
user.get("/:id/blog", listRules, ListBlog);

module.exports = user;
